import path from 'path';
import ip from 'ip';
import base from './config.base'

let rootPath = path.normalize(__dirname + '/..');
let port = 3000
let serverIp = ip.address()

let timespan_second = 1000,
    timespan_minute = 60 * timespan_second,
    timespan_hour = 60 * timespan_minute,
    timespan_day = 24 * timespan_hour

module.exports = {
    ...base,
    "port": port,
    "servicePort": port,
    "serviceHost": serverIp,
    "upload_base": path.join(rootPath, 'uploads/'),
    "public_base": path.join(rootPath, 'public/'),
    "uploadUrl": `http://${serverIp}:${port}/upload`,
    "web_base": path.join(rootPath, '../dist/web/'),
    "db": {
        dbName: 'opsearch',
        userName: 'root',
        password: 'root',
        options: {
            dialect: "mysql",
            host: "127.0.0.1",
            port: 3306,
            logging: function () {
                return true
            },
            operatorsAliases: false,
            dialectOptions: {
                timeout: 30000
            },
            timezone: '+08:00'
        }
    },
    "log": {
        "appenders": [
            {
                type: 'console',
                category: 'default'
            },
            {
                type: 'dateFile',
                filename: 'logs/service',
                pattern: '-yyyy-MM-dd.log',
                alwaysIncludePattern: true,
                level: 'DEBUG',
                category: 'yunchou',
                maxLogSize: 1024 * 5
            }
        ]
    },
    "cache": {
        "name": "memory-cache"
    },
    "query": {pageSize: 10}
};